package com.yyjj.zixun.fragmnet;

import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;

import com.aries.ui.view.title.TitleBarView;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.scwang.smartrefresh.layout.SmartRefreshLayout;
import com.scwang.smartrefresh.layout.api.RefreshLayout;
import com.scwang.smartrefresh.layout.listener.OnRefreshListener;
import com.vise.xsnow.http.ViseHttp;
import com.vise.xsnow.http.callback.ACallback;
import com.yyjj.zixun.R;
import com.yyjj.zixun.adapter.GanTouAdapter;
import com.yyjj.zixun.adapter.ZiXunListAdapter;
import com.yyjj.zixun.api.Api;
import com.yyjj.zixun.entity.BaseGHResp;
import com.yyjj.zixun.entity.BiZiXunEntity;
import com.yyjj.zixun.entity.GtDataResp;
import com.yyjj.zixun.entity.NewsListEntity;
import com.yyjj.zixun.entity.TouJiaoGanHuoEntity;

import java.util.ArrayList;

import tech.com.commoncore.app.FastManager;
import tech.com.commoncore.base.BaseFragment;
import tech.com.commoncore.base.BaseRefreshLoadFragment;
import tech.com.commoncore.base.BaseTitleFragment;
import tech.com.commoncore.base.BaseTitleRefreshLoadFragment;
import tech.com.commoncore.constant.ApiConstant;
import tech.com.commoncore.entity.BaseTResp;


public class GanTouFragment extends BaseFragment {
    GanTouAdapter adapter;
    private RecyclerView recyclerView;
    public static GanTouFragment newInstance() {
        Bundle args = new Bundle();

        GanTouFragment fragment = new GanTouFragment();
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public int getContentLayout() {
        return R.layout.zixun_guantou_fragment;
    }

    @Override
    public void initView(Bundle savedInstanceState) {
        recyclerView = mContentView.findViewById(R.id.rv_contentFastLib);
        adapter = new GanTouAdapter(R.layout.zixun_item_gantou_list);
        recyclerView.setLayoutManager(new LinearLayoutManager(mContext));
        recyclerView.setAdapter(adapter);


        ViseHttp.GET(Api.GANHUO_URL)
                .baseUrl(ApiConstant.BASE_URL)
                .addParam("page",  1 + "")
                .addParam("pagesize", 10 + "")
                .addParam("order", "id")
                .addParam("category", "213")
                .request(new ACallback<BaseGHResp<GtDataResp<ArrayList<TouJiaoGanHuoEntity>>>>() {

                    @Override
                    public void onSuccess(BaseGHResp<GtDataResp<ArrayList<TouJiaoGanHuoEntity>>> data) {
                        if ((1 == data.code) && (data.data != null)) {
                            adapter.setNewData(data.data.data);
                        }
                    }

                    @Override
                    public void onFail(int errCode, String errMsg) {
                    }
                });
    }

}
